(function($, doc) {
	$.init();
	var userinfo = app.getState() || {};
    var Info;
    
	$.plusReady(function() {
		//  点击确认发送
		doc.getElementById('do_send').addEventListener('tap', function() {
			Info={
				user_id: userinfo.user_id,
				account: doc.getElementById('account').value.trim(),
				last_phone: doc.getElementById('last_phone').value.trim(),
				content: doc.getElementById('content').value.trim(),
				etype: 2,
				_token:userinfo.token
			};
			
            if(Info.account==''){
				plus.nativeUI.toast('对方账号不能为空');
				return;
			}
            
			if(Info.account==userinfo.user_id || Info.account==userinfo.mobile){
				plus.nativeUI.toast('接收人不能是自己');
				return;
			}
			
			if(Info.last_phone == '') {
				plus.nativeUI.toast('请输入对方手机号末4位数');
				return;
			}
			if(Info.content.length<5) {
				plus.nativeUI.toast('发送内容至少有5个字');
				return;
			}
			
			
			document.getElementById('account').blur();
			document.getElementById('content').blur();
			document.getElementById('last_phone').blur();
			mui.ajax({
				url: apiurl + "Article/add_book/",
				data: Info,
				async: true,
				dataType: 'json',
				crossDomain: true, //强制使用5+跨域
				type: 'post',
				timeout: 10000,
				success: function(res) {
					console.log(JSON.stringify(res));
					if(res.status ==-3){
						mui.toast(res.msg);
						app.out();
						return false;
					}
					// 请求成功
					if(res.status == 0) {
						mui.alert(res.msg);
					} else {
						mui.toast(res.msg);
						mui.back();
					}
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('获取数据失败！');
				}
			});

		});
		
	
	})
	
}(mui, document));